From b186680a436fb7073b62d468f1f1b4fc4974e5cf Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 24 Aug 2010 16:03:09 +0200 Subject: [PATCH] API: make gtk_icon_view_create_drag_icon() return a cairo_surface_t GdkPixmap is going to die! --- gtk/gtkiconview.c | 32 +++++++++++++++----------------- gtk/gtkiconview.h | 2 +- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c index 9bf5b475e1..90565b4826 100644 --- a/gtk/gtkiconview.c +++ b/gtk/gtkiconview.c @@ -6872,7 +6872,7 @@ gtk_icon_view_drag_begin (GtkWidget *widget, { GtkIconView *icon_view; GtkIconViewItem *item; - GdkPixmap *icon; + cairo_surface_t *icon; gint x, y; GtkTreePath *path; @@ -6897,13 +6897,11 @@ gtk_icon_view_drag_begin (GtkWidget *widget, icon = gtk_icon_view_create_drag_icon (icon_view, path); gtk_tree_path_free (path); - gtk_drag_set_icon_pixmap (context, - gdk_drawable_get_colormap (icon), - icon, - NULL, - x, y); + cairo_surface_set_device_offset (icon, -x, -y); - g_object_unref (icon); + gtk_drag_set_icon_surface (context, icon); + + cairo_surface_destroy (icon); } static void @@ -7474,20 +7472,20 @@ gtk_icon_view_get_dest_item_at_pos (GtkIconView *icon_view, * @icon_view: a #GtkIconView * @path: a #GtkTreePath in @icon_view * - * Creates a #GdkPixmap representation of the item at @path. + * Creates a #cairo_surface_t representation of the item at @path. * This image is used for a drag icon. * - * Return value: (transfer full): a newly-allocated pixmap of the drag icon. + * Return value: (transfer full) a newly-allocated surface of the drag icon. * * Since: 2.8 **/ -GdkPixmap * +cairo_surface_t * gtk_icon_view_create_drag_icon (GtkIconView *icon_view, GtkTreePath *path) { GtkWidget *widget; cairo_t *cr; - GdkPixmap *drawable; + cairo_surface_t *surface; GList *l; gint index; @@ -7507,12 +7505,12 @@ gtk_icon_view_create_drag_icon (GtkIconView *icon_view, if (index == item->index) { - drawable = gdk_pixmap_new (icon_view->priv->bin_window, - item->width + 2, - item->height + 2, - -1); + surface = gdk_window_create_similar_surface (icon_view->priv->bin_window, + CAIRO_CONTENT_COLOR, + item->width + 2, + item->height + 2); - cr = gdk_cairo_create (drawable); + cr = cairo_create (surface); cairo_set_line_width (cr, 1.); gdk_cairo_set_source_color (cr, >k_widget_get_style (widget)->base[gtk_widget_get_state (widget)]); @@ -7534,7 +7532,7 @@ gtk_icon_view_create_drag_icon (GtkIconView *icon_view, cairo_destroy (cr); - return drawable; + return surface; } } diff --git a/gtk/gtkiconview.h b/gtk/gtkiconview.h index cdf79b7fc0..f46d5331b1 100644 --- a/gtk/gtkiconview.h +++ b/gtk/gtkiconview.h @@ -226,7 +226,7 @@ gboolean gtk_icon_view_get_dest_item_at_pos (GtkIconView gint drag_y, GtkTreePath **path, GtkIconViewDropPosition *pos); -GdkPixmap *gtk_icon_view_create_drag_icon (GtkIconView *icon_view, +cairo_surface_t *gtk_icon_view_create_drag_icon (GtkIconView *icon_view, GtkTreePath *path); void gtk_icon_view_convert_widget_to_bin_window_coords (GtkIconView *icon_view, -- 2.30.2